package cap5;
//DrawImage program
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.net.*;
public class DrawImage extends JFrame {
private Image image,image1;
public static void main(String[] args) {
new DrawImage();
}
public DrawImage() {
super("DrawImage");
setSize(600,600);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Toolkit tk = Toolkit.getDefaultToolkit();
image = tk.getImage(getURL("shipBlue.png"));
image1 = tk.getImage(getURL("shipWhite.png"));
}
private URL getURL(String filename) {
URL url = null;
try {
url = this.getClass().getResource(filename);
}
catch (Exception e) { }
return url;
}
public void paint(Graphics g) {
	//create an instance of Graphics2D
	Graphics2D g2d = (Graphics2D) g;
	//fill the background with black
	g2d.setColor(Color.blue);
	g2d.fillRect(0, 0, getSize().width, getSize().height);
	//draw the image
	g2d.drawImage(image, 400, 400, this);
	g2d.drawImage(image1, 60, 200, this);
	}
	}

